
public class prova {

        public static boolean isInCarte(int num, int[] carte){
            num++;
        for(int i=0; i<carte.length; i++){
            if(num==carte[i]){
                return true;
            }
        }
        return false;
    }

    public static void main(String[] args) {
    int[] carte = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40};
        int[] card;
        for (int i = 0; i < 40; i++) {
            card = new int[40 - i];
            int num=0;
            for (int id = 0; id < carte.length; id++) {
                if (carte[id] != 0) {
                    card[num] = carte[id];
                    num++;
                }
            }
            double rand = Math.random();
            rand = rand * card.length-1;
            int randint = (int) rand;
            int pos = card[randint];
            carte[pos-1]=0;
        }
    }
}
